package servlet.Article;

import DAO.ArticleDAO;
import Model.Article;
import appexception.AppException;
import com.fasterxml.jackson.databind.ObjectMapper;
import service.BaseService;
import unit.JSONResponse;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

/**
 * @program: wsn_blog
 * @description：删除文章操作
 * @author:王松年
 * @creat: 2021-07-12 22:17:27
 **/

@WebServlet("/delete")
public class ArticleDeleteServlet extends BaseService {

    @Override
    protected void query(HttpServletRequest req, HttpServletResponse resp) throws SQLException, IOException {
        int id = Integer.parseInt(req.getParameter("id"));
        boolean r = ArticleDAO.delete(id);
        if (!r) {
            throw new AppException("DEL001", "删除失败！");
        }
    }
}